import { ElNotification } from "element-plus";
import { ElMessage } from "element-plus";
import nprogress from "nprogress";


/** 消息通知 */
export function ENotice(message: string, type: any = "success", UseHTMLString: any = false) {
  ElNotification({
    message,
    type: type,
    duration: 3000,
    dangerouslyUseHTMLString: UseHTMLString,
  });
}

/** 消息提示 */
export function EMsg(message: string, type: any  = "error", showClose : boolean = true) {
  ElMessage({
    type: type,
    message: message,
    showClose: showClose,
  });
}

/**
 * n = 3000，3毫秒
*/
export function waitProgress(n){
  var start = Date.now();
    while (true) {
      if (new Date().getTime() - start > n) {
        break;
      } else{
        console.log(new Date().getTime())
      }
    }
}

export function showFullLoading(){
  nprogress.start();
}

export function hideFullLoading(){
  nprogress.done();
}

/**
 * 判断是否是外部链接
 */
export function isExternal(path: string) {
  const isExternal = /^(https?:|http?:|mailto:|tel:)/.test(path);
  return isExternal;
}